package com.syezon.wifikey.cengwang;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;


import com.syezon.wifikey.R;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class NetErrorDialog extends Dialog {

    private ConfirmCallBack mCallBack;

    public static void show(Context context, ConfirmCallBack confirmCallBack) {
        NetErrorDialog countDialog = new NetErrorDialog(context);
        countDialog.setCallBack(confirmCallBack);
        countDialog.show();
    }

    public NetErrorDialog(@NonNull Context context) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.app_tools_alter_dialog);
        ButterKnife.bind(this);
        getWindow().setDimAmount(0.7f);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        setCanceledOnTouchOutside(false);
        setCancelable(false);
        getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    }

    public void setCallBack(ConfirmCallBack callBack) {
        this.mCallBack = callBack;
    }

    @OnClick({R.id.tv_ok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_ok:
                if (mCallBack != null) {
                    mCallBack.confirm();
                }
                dismiss();
                break;
        }
    }

    public interface ConfirmCallBack {
        void confirm();
    }
}
